package solution._0090._0094;

import common.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by chen_snow
 * Date: 2021/7/2 23:09
 * Description: 二叉树的中序遍历
 */
public class Solution {
    public List<Integer> inorderTraversal(TreeNode root) {
        ArrayList<Integer> result = new ArrayList<>();
        traverse(root, result);
        return result;
    }

    public void traverse(TreeNode root, List<Integer> list) {
        if (root == null) {
            return;
        }

        traverse(root.left, list);
        list.add(root.val);
        traverse(root.right, list);
    }
}
